/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassys.dataaccess.hibernate;

import cassys.dataaccess.ModuleDAO;
import cassys.datatransferobjects.AssessmentDTO;
import cassys.datatransferobjects.LecturerDTO;
import cassys.datatransferobjects.ModuleDTO;
import cassys.datatransferobjects.TeamDTO;
import cassys.exceptions.HibernateAccessLayerException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Priyanka
 */
public class ModuleDAOImpl extends AbstractDao implements ModuleDAO {

    @Override
    public void insertModule(ModuleDTO dto) throws HibernateAccessLayerException{
       try {
            //Logger.getLogger(getClass().getName()).log(Level.INFO, "Inserting product" + prod.getProductId());
            super.saveOrUpdate(dto);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public void updatetModule(ModuleDTO dto) {
        try {
            //Logger.getLogger(getClass().getName()).log(Level.INFO, "Inserting product" + prod.getProductId());
            super.saveOrUpdate(dto);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public void deleteModule(ModuleDTO dto) {
        try {
            //Logger.getLogger(getClass().getName()).log(Level.INFO, "Deleting product" + prod.getProductId());
            super.delete(dto);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
        }
    }

    @Override
    public ModuleDTO findModule(String moduleCode) {
     
        ModuleDTO module = null;
        try {
            module = (ModuleDTO) super.find(ModuleDTO.class, moduleCode);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
        }
        return module;
    }

    @Override
    public ModuleDTO[] findAllModules() {
        try {
            List ls = findAll(ModuleDTO.class);
            ModuleDTO[] list = new ModuleDTO[ls.size()];
            ls.toArray(list);
            return list;
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public void insertLecturer(LecturerDTO dto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void updateLecturer(LecturerDTO dto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteLecturer(String lecturerid) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean isExistLecturer(LecturerDTO dto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ArrayList<LecturerDTO> findAllLecturers() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void insertAssessment(AssessmentDTO dto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void updateAssessment(AssessmentDTO dto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteAssessment(String assessmentid) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean isExistAssessment(AssessmentDTO dto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ArrayList<AssessmentDTO> findAllAssessment() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
   
    
}
